set more off

local control attend income male married family_size age hs coll grad white black i.region

eststo clear

foreach dataset in gss ssi {
	use `dataset', clear
	keep if independent == 0
	gen operational2 = .
	
	replace operational2 = -1 if democrat == 1 & operationalc < 0
	replace operational2 = 0 if republican == 1 & operationalc <= 0
	replace operational2 = 0 if democrat == 1 & operationalc >= 0
	replace operational2 = 1 if republican == 1 & operationalc > 0
	replace operational2 = . if mi(operationalc)
	
	/* // gives the same results
	replace operational2 = -1 if liberal == 1 & operationalc < 0
	replace operational2 = 0 if conservative == 1 & operationalc <= 0
	replace operational2 = 0 if liberal == 1 & operationalc >= 0
	replace operational2 = 1 if conservative == 1 & operationalc > 0
	replace operational2 = . if mi(operationalc)
	*/
	
	tabulate operational2, gen(operational2_)
	eststo: xi: reg ln_totgiv operational2_2 operational2_3 `control', robust
}

label variable operational2_2 "Conflicted"
label variable operational2_3 "Consistent Conservative"

#delimit;

esttab
	using "tableA6.tex"
	,
		replace
		width(\textwidth)
		booktabs
		gap
		label
		collabels(none)
 		cells(b(fmt(2) star) se(par))
		drop(*region*)
		stats(
			N 
			r2 
			,
				label(
					"Sample size"
					"R-squared"
				)
				fmt(
					%20.00fc
					%20.02fc
				)
		)
		mtitles("GSS" "SSI")
		;
		
#delimit cr
		

